<template>
  <Swiper>
    <Swiper-item v-for="(item,index) in  banners" :key="index">
      <a :href="item.link">
        <img :src="item.image" alt="" @load="imageLoad">
      </a>
    </Swiper-item>
  </Swiper>
</template>

<script>
  import {Swiper, SwiperItem} from "components/common/swiper/index.js";

  export default {
    name: "HomeSwiper",
    components: {
      Swiper,
      SwiperItem
    },
    data() {
      return {
        //记录是否发出的状态
        isLoad: false,
      }
    },
    props: {
      banners: {
        type: Array,
        default() {
          return []
        }
      }
    },
    methods: {
      imageLoad() {
        /*
        * 下面的操作只会让图片发出一次，本来要发出四次
        * */
        if (!this.isLoad) {
          this.$emit("swiperImageLoad");
          this.isLoad = true;
        }
      }
    }
  }
</script>

<style scoped>

</style>
